﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase" xmlns:Metadata="clr-namespace:Calcium.Themes.BureauBlue.FileMetadata.ResourceDictionaries.Metadata">

	<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
	
	<!--<LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
		<GradientBrush.GradientStops>
			<GradientStopCollection>
				<GradientStop Color="#333" Offset="0.0"/>
				<GradientStop Color="#000" Offset="1.0"/>
			</GradientStopCollection>
		</GradientBrush.GradientStops>
	</LinearGradientBrush>-->

	<!--<SolidColorBrush x:Key="SolidBorderBrush" Color="#444" />
	<SolidColorBrush x:Key="EnabledForegroundBrush" Color="LightGray" />-->
	

	<DataTemplate x:Key="TabHeaderDataTemplate">
		<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch">
			<TextBlock x:Name="textBlock" 
					   Text="{Binding Title}" 
					   HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" 
					   TextWrapping="NoWrap" Margin="0,2,0,0"  
					   FontFamily="Arial" FontSize="11" />
			<TextBlock Text="*" 
					   Visibility="{Binding Path=Content.Dirty, FallbackValue=Collapsed, Converter={StaticResource BooleanToVisibilityConverter}}"
					   HorizontalAlignment="Left" Margin="0,2,0,0" />
			<Button x:Name="button"  
					Command="ApplicationCommands.Close" CommandParameter="{Binding diagnostics:PresentationTraceSources.TraceLevel=None, Path=Content, RelativeSource={RelativeSource AncestorType={x:Type TabItem}, Mode=FindAncestor}}" 
					Template="{DynamicResource CloseTabButtonControlTemplate}" 
					Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" 
					Width="9" Height="9" Opacity="1" ToolTip="Close" 
					Margin="8,3,0,0" VerticalAlignment="Stretch" BorderThickness="0"
					HorizontalAlignment="Right" />

		</StackPanel>
	</DataTemplate>

	<Style TargetType="{x:Type TabItem}" >
		<Setter Property="Header" Value="{Binding ViewModel}" />
		<Setter Property="HeaderTemplate" Value="{DynamicResource TabHeaderDataTemplate}" />
		<Setter Property="Padding" Value="10,6,10,6" />
		<Setter Property="MinWidth" Value="5" />
		<Setter Property="MinHeight" Value="5" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type TabItem}">
					<ControlTemplate.Resources>
						<Storyboard x:Key="SelectedOn">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="SelectedState" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="UnSelectedState" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0" />
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="SelectedOff">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="UnSelectedState" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1" />
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="SelectedState" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="HoverOn">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TopUnselectedOver" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TopUnselectedBorderOver" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="HoverOff">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TopUnselectedOver" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
							</DoubleAnimationUsingKeyFrames>
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TopUnselectedBorderOver" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="FocusedOn">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualTop" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
						<Storyboard x:Key="FocusedOff">
							<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualTop" Storyboard.TargetProperty="(UIElement.Opacity)">
								<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
							</DoubleAnimationUsingKeyFrames>
						</Storyboard>
					</ControlTemplate.Resources>
					<Grid x:Name="grid" Margin="2,1,2,0">
						<Grid.LayoutTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="1" ScaleY="1" />
								<SkewTransform AngleX="0" AngleY="0" />
								<RotateTransform Angle="0" />
								<TranslateTransform X="0" Y="0" />
							</TransformGroup>
						</Grid.LayoutTransform>
						<Grid>

							<Grid Margin="1,0,1,0" x:Name="UnSelectedState">
								<Border x:Name="TopUnselectedOver" BorderBrush="{DynamicResource TabItemHoverBorderBrush}" BorderThickness="1,1,1,0" CornerRadius="2.21,2.21,.5,.5" Opacity="0" Background="{DynamicResource TabItemHoverBrush}"/>
								<Border x:Name="TopUnselectedBorderOver" Margin="-1,-1,-1,0.5" BorderBrush="{DynamicResource TabItemHoverHighlightBrush}" BorderThickness="1,1,1,0" CornerRadius="3.5,3.5,0,0" Opacity="0" />
								<Border x:Name="UnselectedBorderTop" BorderThickness="2,0,2,0" CornerRadius="3,3,0,0" BorderBrush="{DynamicResource TabItemBorderTopBrush}"/>
								<Border x:Name="UnselectedHighlightTop" Margin="2,0,2,0" BorderThickness="1,3,1,0" CornerRadius="1.25,1.25,0,0" BorderBrush="{DynamicResource TabItemHighlightTopBrush}"/>
								<Border x:Name="UnselectedBorderTop2" Margin="-1,0,-1,0" BorderBrush="{DynamicResource TabItemBorderTop2Brush}" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0" IsHitTestVisible="false" />
								<Border x:Name="UnselectedFocusVisualTop" Margin="-1,0,-1,0" BorderThickness="3,2,3,0" CornerRadius="3,3,0,0" Opacity="0" BorderBrush="{DynamicResource TabItemFocusBrush}">
								</Border>
							</Grid>
							<Grid Margin="1,0,1,-1" x:Name="SelectedState" Opacity="0">
								<Border x:Name="BackgroundTop" BorderBrush="{DynamicResource TabItemSelectedBorderBrush}" BorderThickness="2,0,2,0" CornerRadius="3,3,0,0" Background="{DynamicResource TabItemSelectedBrush}"/>
								<Border x:Name="BorderTop" BorderThickness="2,0,2,0" CornerRadius="3,3,0,0" BorderBrush="{DynamicResource TabItemBorderTopBrush}"/>
								<Border x:Name="HighlightTop" Margin="2,0,2,0" BorderThickness="1,3,1,0" CornerRadius="1.25,1.25,0,0" BorderBrush="{DynamicResource TabItemHighlightTopBrush}"/>
								<Border x:Name="BorderTop2" Margin="-1,0,-1,0" BorderBrush="{DynamicResource TabItemBorderTop2Brush}" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0" IsHitTestVisible="false" />
								<Border x:Name="FocusVisualTop" Margin="-1,0,-1,0" BorderThickness="3,2,3,0" CornerRadius="3,3,0,0" Opacity="0" BorderBrush="{DynamicResource TabItemFocusBrush}">
								</Border>
							</Grid>
							<Border x:Name="DisabledVisualTopSelected" Margin="1,0,1,0" Background="{DynamicResource DisabledBackgroundBrush}" CornerRadius="3,3,0,0" IsHitTestVisible="false" Visibility="Collapsed" />
							<ContentPresenter HorizontalAlignment="Center" Margin="{TemplateBinding Padding}" x:Name="ContentSite" VerticalAlignment="Center" RecognizesAccessKey="True" ContentSource="Header" />

						</Grid>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsFocused" Value="True">
							<Trigger.ExitActions>
								<BeginStoryboard Storyboard="{StaticResource FocusedOff}" x:Name="FocusedOff_BeginStoryboard" />
							</Trigger.ExitActions>
							<Trigger.EnterActions>
								<BeginStoryboard Storyboard="{StaticResource FocusedOn}" x:Name="FocusedOn_BeginStoryboard" />
							</Trigger.EnterActions>
						</Trigger>
						<Trigger Property="TabStripPlacement" Value="Left">
							<Setter Property="LayoutTransform" TargetName="grid">
								<Setter.Value>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1" />
										<SkewTransform AngleX="0" AngleY="0" />
										<RotateTransform Angle="-90" />
										<TranslateTransform X="0" Y="0" />
									</TransformGroup>
								</Setter.Value>
							</Setter>
						</Trigger>
						<Trigger Property="TabStripPlacement" Value="Right">
							<Setter Property="LayoutTransform" TargetName="grid">
								<Setter.Value>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1" />
										<SkewTransform AngleX="0" AngleY="0" />
										<RotateTransform Angle="90" />
										<TranslateTransform X="0" Y="0" />
									</TransformGroup>
								</Setter.Value>
							</Setter>
						</Trigger>
						<Trigger Property="TabStripPlacement" Value="Bottom">
							<Setter Property="LayoutTransform" TargetName="ContentSite">
								<Setter.Value>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1" />
										<SkewTransform AngleX="0" AngleY="0" />
										<RotateTransform Angle="180" />
										<TranslateTransform X="0" Y="0" />
									</TransformGroup>
								</Setter.Value>
							</Setter>
							<Setter Property="LayoutTransform" TargetName="grid">
								<Setter.Value>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1" />
										<SkewTransform AngleX="0" AngleY="0" />
										<RotateTransform Angle="180" />
										<TranslateTransform X="0" Y="0" />
									</TransformGroup>
								</Setter.Value>
							</Setter>
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.ExitActions>
								<BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard" />
							</MultiTrigger.ExitActions>
							<MultiTrigger.EnterActions>
								<BeginStoryboard Storyboard="{StaticResource HoverOn}" x:Name="HoverOn_BeginStoryboard" />
							</MultiTrigger.EnterActions>
							<MultiTrigger.Conditions>
								<Condition Property="IsMouseOver" Value="True" />
								<Condition Property="Selector.IsSelected" Value="False" />
							</MultiTrigger.Conditions>
						</MultiTrigger>
						<Trigger Property="IsSelected" Value="True">
							<Trigger.ExitActions>
								<BeginStoryboard Storyboard="{StaticResource SelectedOff}" x:Name="SelectedOff_BeginStoryboard" />
							</Trigger.ExitActions>
							<Trigger.EnterActions>
								<BeginStoryboard Storyboard="{StaticResource SelectedOn}" />
							</Trigger.EnterActions>
							<Setter Property="Panel.ZIndex" Value="100" />
							
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsMouseOver" Value="True" SourceName="grid" />
								<Condition Property="Selector.IsSelected" Value="True" />
							</MultiTrigger.Conditions>
						</MultiTrigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Setter Property="Foreground">
			<Setter.Value>
				<SolidColorBrush Color="Gray" />
			</Setter.Value>
		</Setter>
		<Style.Triggers>
			<Trigger Property="Selector.IsSelected" Value="True">
				<Setter Property="Foreground" Value="{DynamicResource OutsideFontColor}" />
			</Trigger>
		</Style.Triggers>
	</Style>
		<!--<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type TabItem}">
					<Grid>
						<Border 
							Name="Border"
							Margin="0,0,-4,0" 
							Background="{StaticResource LightBrush}"
							BorderBrush="{StaticResource SolidBorderBrush}" 
							BorderThickness="1,1,1,1" 
							CornerRadius="2,12,0,0">
							<ContentPresenter x:Name="ContentSite"
							  VerticalAlignment="Center"
							  HorizontalAlignment="Center"
							  ContentSource="Header"
							  Margin="12,2,12,2"
							  RecognizesAccessKey="True" />
						</Border>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsSelected" Value="True">
							<Setter Property="Panel.ZIndex" Value="100" />
							<Setter TargetName="Border" Property="Background" Value="{DynamicResource {x:Static m:ThemeXamlMetadata.WindowBackgroundBrushKey}}" />
							<Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter TargetName="Border" Property="Background" Value="{DynamicResource {x:Static m:ThemeXamlMetadata.DisabledBackgroundBrushKey}}" />
							<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource {x:Static m:ThemeXamlMetadata.DisabledBorderBrushKey}}" />
							<Setter Property="Foreground" Value="{DynamicResource {x:Static m:ThemeXamlMetadata.DisabledForegroundBrushKey}}" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="true">
							<Setter Property="Foreground" Value="{StaticResource EnabledForegroundBrush}" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>-->

</ResourceDictionary>